//
//  HWExchangeButton.m
//  嗨文
//
//  Created by 响当当 on 3/29/19.
//  Copyright © 2019 dongzheng. All rights reserved.
//

#import "HWExchangeButton.h"

@interface HWExchangeButton ()
@property (nonatomic, strong)UILabel *moneyLabel;//金钱
@property (nonatomic, strong)UILabel *timeLabel;//时间
@end

@implementation HWExchangeButton

- (UILabel *)moneyLabel
{
    if (!_moneyLabel)
    {
        _moneyLabel = [HWUtilties creatLabelWithFrame:CGRectMake(0,22*kUIScaleBasePlus,self.frame.size.width,20*kUIScaleBasePlus)
                                         textAligment:NSTextAlignmentCenter
                                             textClor:LCHexColor(0xF54337)
                                             textFont:25*kUIScaleBasePlus];
    }
    return _moneyLabel;
}

- (UILabel *)timeLabel
{
    if (!_timeLabel)
    {
        _timeLabel = [HWUtilties creatLabelWithFrame:CGRectMake(0,CGRectGetMaxY(self.moneyLabel.frame)+5*kUIScaleBasePlus,self.frame.size.width,20*kUIScaleBasePlus)
                                        textAligment:NSTextAlignmentCenter
                                            textClor:LCHexColor(0x343434)
                                            textFont:12*kUIScaleBasePlus];
    }
    return _timeLabel;
}

- (instancetype)initWithFrame:(CGRect)frame
{
    self = [super initWithFrame:frame];
    if (self)
    {
        self.layer.masksToBounds = YES;
        self.layer.cornerRadius = 4;
        self.layer.borderColor = LCHexColor(0xF54337).CGColor;
        self.layer.borderWidth = 1;
        
        [self addSubview:self.moneyLabel];
        [self addSubview:self.timeLabel];
        
    }
    return self;
}

- (void)getRechargeDate:(NSDictionary *)dic
{
    
    NSString *goodsNum = [NSString stringWithFormat:@"%@",dic[@"time"]];
    NSString *moneyStr = [NSString stringWithFormat:@"%@",dic[@"money"]];
    
    self.moneyLabel.attributedText = [moneyStr addAttriButedString:[NSString stringWithFormat:@"%@元",moneyStr]
                                                             Color:LCHexColor(0xF54337)
                                                              Font:[UIFont systemFontOfSize:16*kUIScaleBasePlus]
                                                              rang:NSMakeRange(0,0)];
    
    self.timeLabel.text = [NSString stringWithFormat:@"%@金币",goodsNum];
}

- (void)changeColor:(NSInteger)idx
{
    if (idx == 1)
    {
        self.moneyLabel.textColor = LCHexColor(0xF54337);
        self.timeLabel.textColor = LCHexColor(0x343434);
        self.backgroundColor = [UIColor clearColor];
    }
    else
    {
        self.moneyLabel.textColor = [UIColor whiteColor];
        self.timeLabel.textColor = [UIColor whiteColor];
        self.backgroundColor = LCHexColor(0xF54337);
    }
}
@end
